package com.dykj.fireFighting.web.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dykj.fireFighting.api.base.effecttimesetting.entity.EffectiveTimeSetting;
import com.dykj.fireFighting.api.base.generator.entity.TableEntity;
import com.dykj.fireFighting.web.model.Device;
import com.dykj.fireFighting.web.model.DeviceFault;
import com.dykj.fireFighting.web.model.report.DevHis;
import com.dykj.fireFighting.web.model.report.DevHisJar;
import com.dykj.fireFighting.web.model.report.DevHisWater;
import com.dykj.fireFighting.web.model.report.FaultRecoveryRecord;
import com.dykj.fireFighting.web.model.vo.DevHisVo;
import org.apache.ibatis.annotations.Param;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created by admin on 2019-9-17.
 */
public interface DevHisMapper extends BaseMapper<TableEntity> {
    //DevHis queryCreateBy(String devCode, String wh, String code);
    int updateTopRui(Device device);
    Device queryCreateBy(String relationId);
    int insertHis(@Param("tableName")String tableName,@Param("devHis") DevHis devHis);

    int insertFaultRecoveryRecord(FaultRecoveryRecord faultRecoveryRecord);

    /**
     * 查询当前周火警，故障，反馈数量
     * @param map
     * @return
     */
    DevHis selectWeekSum(Map<String, Object> map);
    /**
     * 查询当前月火警，故障，反馈数量
     * @param map
     * @return
     */
    DevHis selectMonthSum(Map<String, Object> map);
    /**
     * 查询当前年火警，故障，反馈数量
     * @param map
     * @return
     */
    DevHis selectYearSum(Map<String, Object> map);
    /**
     * 查询当前季度火警，故障，反馈数量
     * @param map
     * @return
     */
    DevHis selectMonthsSum(Map<String, Object> map);
    /**
     * 查询未读故障数量
     * @param gridCode 社会单位code
     * @return int
     */
    int selectUnread(String gridCode);

    /**
     * 修改阅读状态
     * @param code code
     * @return boolean
     */
    boolean updateReadStatus(String code);
    int insertDevHisWater(@Param("tableName")String tableName,@Param("devHisWater") DevHisWater devHisWater);
    /**
     * 获取水设备当前状态
     * @param relationId
     * @return
     */
    String getWaterDevStatus(String relationId);

    /**
     * 获取报警设备附近的设备
     * @param params
     * @return
     */
    List<Device> getDevices(Map<String, String> params);

    /**
     * 根据设备id获取一定时间段内的报警数据
     * @return
     */
    List<DevHisVo> getDevHisByIds(@Param("tableName") String tableName,@Param("devIds") String[] devIds, @Param("ztfssj") String ztfssj);
    DevHis getNewestGz(String relationId);
    EffectiveTimeSetting getEffectiveTime(String unitId);
    int insertFaultDevice(DeviceFault deviceFault);
    int updateFaultDevice(DeviceFault deviceFault);
    DeviceFault queryByRelationId(String relationId);
    int deleteFaultDevice(String id);
}
